<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Change the size of an array</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="splfixedarray.rewind.html">SplFixedArray::rewind</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="splfixedarray.toarray.html">SplFixedArray::toArray</a></div>
 <div class="up"><a href="class.splfixedarray.html">SplFixedArray</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="splfixedarray.setsize" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SplFixedArray::setSize</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0)</p><p class="refpurpose"><span class="refname">SplFixedArray::setSize</span> &mdash; <span class="dc-title">Change the size of an array</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-splfixedarray.setsize-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span> <span class="methodname"><strong>SplFixedArray::setSize</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$size</code></span>
   )</div>

  <p class="para rdfs-comment">
   Change the size of an array to the new size of <em><code class="parameter">size</code></em>. If 
   <em><code class="parameter">size</code></em> is less than the current array size, any values after the new size 
   will be discarded. If <em><code class="parameter">size</code></em> is greater than the current array size, the 
   array will be padded with <strong><code>NULL</code></strong> values.
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-splfixedarray.setsize-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">size</code></em></dt>

     <dd>

      <p class="para">
       The new array size. This should be a value between <em>0</em> and <strong><code>PHP_INT_MAX</code></strong>.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-splfixedarray.setsize-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>

 
 
 <div class="refsect1 errors" id="refsect1-splfixedarray.setsize-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   Throws <a href="class.invalidargumentexception.html" class="classname">InvalidArgumentException</a> when <em><code class="parameter">size</code></em> is less than zero.
  </p>
  <p class="para">
   Raises <strong><code>E_WARNING</code></strong> when <em><code class="parameter">size</code></em> cannot be used as a number.
  </p> 
 </div>

 
 
 <div class="refsect1 examples" id="refsect1-splfixedarray.setsize-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3712">
    <p><strong>Example #1 <span class="function"><strong>SplFixedArray::setSize()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;$array&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SplFixedArray</span><span style="color: #007700">(</span><span style="color: #0000BB">5</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$array</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getSize</span><span style="color: #007700">().</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$array</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setSize</span><span style="color: #007700">(</span><span style="color: #0000BB">10</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$array</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getSize</span><span style="color: #007700">().</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
5
10
</pre></div>
    </div>
   </div>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="splfixedarray.rewind.html">SplFixedArray::rewind</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="splfixedarray.toarray.html">SplFixedArray::toArray</a></div>
 <div class="up"><a href="class.splfixedarray.html">SplFixedArray</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
